#ifndef _cesium_sampler_stage_hpp_
#define _cesium_sampler_stage_hpp_

#include "cesium/stage.hpp"
#include "cesium/sinkset.hpp"

namespace Cesium {

template<typename SamplerType>
class SamplerStage : public Stage {
public:
    SamplerStage(const SamplerType& _sampler)
     : sampler(_sampler)
    {
    }
    SamplerStage(const SamplerType& _sampler, Stage* sink)
     : sampler(_sampler)
    {
        sinks.add(sink);
    }
    virtual ~SamplerStage() {
    }

    virtual void signal(Stage* src, Buffer* data, BufferRange range) {
        if (sampler.sample(data, range))
            sinks.signal(this, data, range);
    }

private:
    SamplerType sampler;
    SinkSet sinks;
}; // class SamplerStage

} // namespace Cesium

#endif //_cesium_sampler_stage_hpp_
